package com.jiyun.controller;

import com.jiyun.entity.day07.Training;
import com.jiyun.feign.TrainingFeign;
import com.jiyun.vo.ResponseBean;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("training")
public class TrainingController {
    @Resource
    private TrainingFeign trainingFeign;

    /**
     * 遍历
     * @param training
     * @return
     */
    @RequestMapping("/findByAll")
    private ResponseBean findAll(@RequestBody Training training){
        return trainingFeign.findByAll(training);
    }

    /**
     * 根据培训表id查询数据
     * @param id
     * @return
     */
    @RequestMapping("/findByTrainingId")
    private ResponseBean findByTrainingId(@RequestParam Integer id){
        return trainingFeign.findByTrainingId(id);
    }
    /**
     * 添加中间表信息
     */
    @RequestMapping("/addUserTraining")
    private ResponseBean addUserTraining(@RequestParam Integer id){
        return trainingFeign.addUserTraining(id);
    }

    /**
     * 根据redis中的用户查询数据
     * @return
     */
    @RequestMapping("/findTrainingByUser")
    private ResponseBean findTrainingByUser(){
        return trainingFeign.findTrainingByUser();
    }


}
